package com.example.park2212.points

import androidx.lifecycle.MutableLiveData
import com.example.lib_base.entity.*

import com.example.lib_base.mvvm.BaseViewModel
import com.example.lib_base.net.ApiService
import dagger.hilt.android.lifecycle.HiltViewModel
import javax.inject.Inject

@HiltViewModel
class PointsViewModel@Inject constructor(val apiService: ApiService):BaseViewModel() {

    val pointsSuccess = MutableLiveData<PointsBeanItem>()
    fun points(){
        httpRequest({
            apiService.getPoints()
        },pointsSuccess::postValue)
    }

    val addPointSuccess  =MutableLiveData<PointsBeanItemItem>()
    fun addPoints(item: PointsBeanItemItem){
        httpRequest({
            apiService.addPoints(mapToBody(item))
        },addPointSuccess::postValue)
    }

    val deletePointsSuccess = MutableLiveData<Boolean>()
    fun deletePoints(id: Int){
        httpRequest({
            apiService.deletePoints(id)
        },deletePointsSuccess::postValue)
    }

    val detailPointsSuccess = MutableLiveData<PointsBeanItemItem>()
    fun detailPoints(id: Int){
        httpRequest({
            apiService.detailPoints(id)
        },detailPointsSuccess::postValue)
    }

     var getPointById = MutableLiveData<PointsBeanItemItem>()
    fun getPointsById(id:Int){
        httpRequest({apiService.getPointById(id)},getPointById::postValue)
    }


    var getTasks = MutableLiveData<PatrolTaskBean>()
    fun getTasks(){
        httpRequest({apiService.getPatrolTasks()},getTasks::postValue)
    }

    val getOrderSuccess = MutableLiveData<RepairBean>()
    fun getOrder(){
        httpRequest({
            apiService.getOrders()
        },getOrderSuccess::postValue)
    }

    val orderSuccess = MutableLiveData<PatrolTaskBean>()
    fun order(status:String){
        httpRequest({
            apiService.order(status)
        },orderSuccess::postValue)
    }

    val getTaskByIdSuccess = MutableLiveData<PatrolTaskBeanItem>()
    fun getTaskById(id:Int){
        httpRequest({
            apiService.getTaskById(id)
        },getTaskByIdSuccess::postValue)
    }


}